﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Meraz.Core.Model
{
    public class Role : IEquatable<Role>
    {
        public int ID { get; set; }
        public string RoleName { get; set; }
        public string ApplicationName { get; set; }

        public override bool Equals(object obj)
        {
            if (obj == null)
                return false;
            return Equals((Role)obj);
        }
        public override int GetHashCode()
        {
            return RoleName.GetHashCode() ^ ApplicationName.GetHashCode();
        }
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("{");
            builder.AppendFormat("{0}: {1}, ", "ID", ID);
            builder.AppendFormat("{0}: '{1}', ", "ApplicationName", ApplicationName);
            builder.AppendFormat("{0}: '{1}'", "RoleName", RoleName);
            builder.Append("}");
            return builder.ToString();
        }
        public bool Equals(Role other)
        {
            if (other == null)
                return false;
            if (!ApplicationName.Equals(other.ApplicationName))
                return false;
            if (!RoleName.Equals(other.RoleName))
                return false;
            if (other.ID == 0)
                return true;
            return ID.Equals(other.ID);
        }
    }
}
